Skip to content

Add PermissionedDomain to LoanBroker#484

Open
Tapanito wants to merge 4 commits intomasterfrom
tapanito/lending-domain
Open

Add PermissionedDomain to LoanBroker#484
Tapanito wants to merge 4 commits intomasterfrom
tapanito/lending-domain

Conversation

@Tapanito
Copy link
Collaborator

High Level Overview of Change

Introduces access control for the Lending Protocol via Permissioned Domains. A LoanBroker can be configured as private at creation time, restricting loan issuance to Borrowers with valid credentials.

Changes:

  • Add DomainID field and lsfLoanBrokerPrivate flag to the LoanBroker ledger entry
  • Add tfLoanBrokerPrivate transaction flag to LoanBrokerSet
  • Add failure conditions for credential validation on LoanSet
  • Add Access Control section (3.1.13) documenting the feature behavior
  • Add invariants for the private flag and domain relationship
  • The domain can be changed or cleared after creation; the private flag is immutable
  • Credential checks do not apply to LoanPay, Borrowers can always repay

Context of Change

Type of Change

  • New XLS Draft
  • XLS Update (changes to an existing XLS)
  • XLS Status Change (e.g., Draft → Final, Draft → Stagnant)
  • Process/Meta (changes to CONTRIBUTING.md, XLS-1, templates, etc.)
  • Infrastructure (CI, workflows, scripts, website)
  • Documentation (README updates, typo fixes)

@Tapanito Tapanito changed the title Tapanito/lending domain Add PermissionedDomain to LoanBroker Feb 26, 2026
9. If `LoanBrokerID` is specified (modifying existing):
1. `LoanBrokerID` is empty. (`temINVALID`)
2. Submitter is attempting to modify fixed fields (`ManagementFeeRate`, `CoverRateMinimum`, `CoverRateLiquidation`). (`temINVALID`)
3. Submitter is attempting to modify `tfLoanBrokerPrivate` flag on an existing `LoanBroker`. (`temINVALID`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that because of the nature of the Flags field, and the existence of universal flags, having the tfLoanBrokerPrivate field unset should be ignored - not treated as trying to change the flag.

Conversely, if the flag is set, that should always return as temINVALID regardless of the state of the LoanBroker object. (If it's already set, then the flag is redundant. If it's not set, then that's an attempted change.) At the implementation level, that means this check can be done in preflight - you don't need to know the current state of the LoanBroker object.

So I would suggest rephrasing this as something like

The `tfLoanBrokerPrivate` flag is set in the transaction

#### 3.3.6 Invariants

#### 3.3.6 Example JSON
1. If `LoanBroker.lsfLoanBrokerPrivate` flag is set, it cannot be unset.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Info: Since there are no other ledger flags defined for the loan broker object, this means that the Flags field can not be changed, and so this can be checked in NoModifiedUnmodifiableFields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a1q123456 fyi.

14. `PaymentTotal <= 0`. (`temINVALID`)
15. `PaymentInterval` is less than `60` seconds. (`temINVALID`)
16. `GracePeriod` is less than `60` seconds or greater than the `PaymentInterval`. (`temINVALID`)
17. The `Counterparty` field is not specified and the `CounterpartySignature` is not from the `LoanBroker.Owner`. (`temBAD_SIGNER`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a protocol-level check, because it requires loading the LoanBroker.Owner's account root and/or signers list. For example, the owner may have a regular key defined. The transactor can't know that the regular key is allowed to sign for the owner without loading AccountRoot(LoanBroker.Owner) to get the sfRegularKey field.

If the signer(s) in the CounterpartySignature is/are not allowed, the failure code will be a tef, depending on which failure case is hit. e.g. tefMASTER_DISABLED, tefBAD_AUTH, tefNOT_MULTI_SIGNING, tefBAD_SIGNATURE, tefBAD_QUORUM. There may be others.

temBAD_SIGNER is only relevant to LoanSet if

  1. it's a Batch inner tx and theCounterparty is not set, or
  2. if it's a normal tx and there is no CounterpartySignature at all, or
  3. if there is no Counterparty set and the LoanBroker(LoanBrokerID) doesn't exist on ledger.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I captured the other temBAD_SIGNER errors, and moved this particular failure down to protocol checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants